﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace System.Windows.JControls.JColorPicker
{
    partial class FormColorDialogHandler : Form
    {
        public event EventHandler SelectedColorChanged;

        public FormColorDialogHandler()
        {
            InitializeComponent();
        }

        public HSB HSB
        {
            get { return jColorPickerControl1.HSB; }
            set
            { jColorPickerControl1.HSB = value; }
        }

        public RGB RGB
        {
            get { return jColorPickerControl1.RGB; }
            set { jColorPickerControl1.RGB = value; }
        }

        public Color SelectedColor
        {
            get { return jColorPickerControl1.SelectedColor; }
            set { jColorPickerControl1.SelectedColor = value; }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            this.Close();
        }

        #region Event

        void jsColorPickerControl1_SelectedColorChanged(object sender, EventArgs e)
        {
            OnSelectedColorChanged(sender, e);
        }

        protected virtual void OnSelectedColorChanged(object sender, EventArgs args)
        {
            if (SelectedColorChanged != null)
            {
                SelectedColorChanged(sender, args);
            }
        }

        #endregion
    }
}
